/**
 * huoyunren.com Inc.
 * Copyright (c) 2004-2014 All Rights Reserved.
 */
package com.smarttest.common.constants;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.smarttest.common.util.CollectionUtils;



/**
 * @author wuzhuqu 2015年1月13日
 *
 */
public final class SmartConstant {

    /**传感器正在初始化*/
    public static final Integer SENSOR_INIT = 0xFFFD;

    /**传感器故障*/
    public static final Integer SENSOR_ERROR = 0xFFFE;

    /**无传感器*/
    public static final Integer SENSOR_NONE = 0xFFFF;

    public static final String BATTERY_VOL = "batteryVol";
    
    public static final String MAIN_VOL = "mainVol";
    
    public static final String SOFTWARE_VERSION = "softwareVersion";
    public static final String SOFTWARE_VERSION_RESULT = "softwareVersionResult";
    public static final String DEFAULT_PHONE = "01234567890";

    /**
     * 文本消息下发
     *
     */
    public static class TEXT_MSG {
        /** 文本消息下发-紧急 */
        public static final int URGENCY = 1;
        /** 文本消息下发-终端显示器显示 */
        public static final int DISLAY = 4;
        /** 文本消息下发-终端TTS播读*/
        public static final int TTS = 8;
        /** 文本消息下发-广告屏显示*/
        public static final int ADDISPLAY = 16;
        /** 文本消息下发-终端显示加语音*/
        public static final int DISPLAY_AND_TTS = 12;
    }

    /** 终端通用应答结果映射 */
    public static final Map<Integer, String> RESULT_MAPPING = new HashMap<Integer, String>() {
        /** 序列化 */
        private static final long serialVersionUID = -2943340983439047378L;

        {
            put(0, "成功/确认");
            put(1, "失败");
            put(2, "消息有误");
            put(3, "不支持");
        }
    };

    /** 收到这些应答消息需要入库日志 */
    public static final List<Integer> NEED_LOG_LIST = new ArrayList<Integer>() {
        /**  */
        private static final long serialVersionUID = 1L;

        {
            add(CmdConstant.CMD_0x8003);
            add(CmdConstant.CMD_0x8004);
            add(CmdConstant.CMD_0x8005);
            add(CmdConstant.CMD_0x8006);
            add(CmdConstant.CMD_0x8007);
            add(CmdConstant.CMD_0x8008);
            add(CmdConstant.CMD_0x8009);
            add(CmdConstant.CMD_0x800A);
            add(CmdConstant.CMD_0x8200);
            add(CmdConstant.CMD_0x8503);
            add(CmdConstant.CMD_0x8600);
            add(CmdConstant.CMD_0x8601);
            add(CmdConstant.CMD_0x8602);
            add(CmdConstant.CMD_0x8603);
            add(CmdConstant.CMD_0x8604);
            add(CmdConstant.CMD_0x8605);
            add(CmdConstant.CMD_0x8606);
            add(CmdConstant.CMD_0x8607);
            add(CmdConstant.CMD_0x8801);
            add(CmdConstant.CMD_0x8803);
            add(CmdConstant.CMD_0x8805);
            add(CmdConstant.CMD_0x8900);
        }
    };

    /**升级类型（0：自动升级，1：手动升级）*/
    public static class OtaType {
        public static final String AUTO = "0";
        public static final String MANUAL = "1";
    }

    /**升级状态（A：配置记录，0：升级初始化，1: 升级中，2：补传中，3：成功，4：失败）*/
    public static class OtaStatus {
        /**配置记录*/
        public static final String CONFIG = "A";

        /**升级初始化*/
        public static final String INIT = "0";

        /**升级中*/
        public static final String PROCESSING = "1";

        /**补传中*/
        public static final String SUPPLE = "2";

        /**成功*/
        public static final String SUCC = "3";

        /**失败*/
        public static final String FAIL = "4";

        /**中止升级失败*/
        public static final String STOP_FAIL = "5";

        /**中止升级失败*/
        public static final String STOP_SUCC = "6";
    }

    /**强制升级（0：不强制升级，1：强制升级）*/
    public static class ForciblyUpgrade {
        /**0：不强制升级*/
        public static final String VOLUNTEER = "0";

        /**1：强制升级*/
        public static final String FORCE = "1";
    }

    /**自动升级开关(0: 关闭，1：开启)*/
    public static class AutoOtaUpgrade {
        /**开启*/
        public static final String OPENING = "1";

        /**关闭*/
        public static final String CLOSED = "0";
    }

    /**SmartOTA升级状态*/
    public static class UpgradeStatus {
        /**升级失败*/
        public static final String FAIL = "5";

        /**升级成功*/
        public static final String SUCC = "6";

        /**中止升级失败*/
        public static final String STOP_FAIL = "7";

        /**中止升级成功*/
        public static final String STOP_SUCC = "8";
    }

    /**升级类型 1：开始升级 0：终止升级*/
    public static final class UpgradeType {
        /**1：开始升级*/
        public static final String START = "1";

        /**0：终止升级*/
        public static final String STOP = "0";
    }

    /**8003终端控制类型*/
    public class ControlType {
        /**终端复位*/
        public static final int TERMINAL_RESET = 1;

        /**切换到升级服务器*/
        public static final int CHANAGE_TO_TEST_UPGRADE = 2;

        /**切换到正式服务器*/
        public static final int CHANAGE_TO_TEST_FORMAL = 3;
    }

    /**SmartOTA升级描述*/
    public static final Map<String, String> UpgradeDesc = CollectionUtils.asMap(
            UpgradeStatus.FAIL, "升级失败",
            UpgradeStatus.SUCC, "升级成功",
            UpgradeStatus.STOP_FAIL, "中止升级失败",
            UpgradeStatus.STOP_SUCC, "中止升级成功"
            );

    /**传感器状态*/
    public static final Map<Integer, Integer> SENSOR_STATUS = new HashMap<Integer, Integer>() {
        /**序列化*/
        private static final long serialVersionUID = -2943340983439047378L;

        {
            put(SENSOR_INIT, 3001);
            put(SENSOR_ERROR, 3002);
            put(SENSOR_NONE, 3003);
        }
    };

    /**冷链报警类型*/
    public abstract class COLDCHAIN_ALARM_TYPE {
        /**温度报警*/
        public static final String ALARMT = "alarmt";

        /**湿度报警*/
        public static final String ALARMM = "alarmm";
    }

    /**设备连接服务器状态信息*/
    public interface ConnServerStatus {
        /**正式服务器*/
        public static final String FORMAL_SERVER = "2";

        /**升级服务器*/
        public static final String UPGRADE_SERVER = "1";
    }
    
    /**PLV附加信息指令集合*/
    public interface PlvCmds {
        /**当前时间*/
        public static final int CMD_0X000B = 0x000B;
    }
    
}
